package com.car.loan.project.xr.controller.search;

import com.car.loan.framework.aspectj.lang.annotation.DataStatus;
import com.car.loan.framework.web.domain.AjaxResult;
import com.car.loan.project.xr.service.ILoanService;
import com.car.loan.project.xr.service.SearchService;
import com.car.loan.project.xr.util.bo.business.LoanBaseInfo;
import com.car.loan.project.xr.util.bo.business.LoanDeletePageParam;
import com.car.loan.project.xr.util.bo.business.LoanUrgentPageParam;
import com.car.loan.project.xr.util.select.LoanBasePageParam;
import com.car.loan.project.xr.util.vo.LoanDeleteVo;
import com.car.loan.project.xr.util.vo.SearchDeleteVo;
import com.car.loan.project.xr.util.vo.SearchBusinessVo;
import com.car.loan.project.xr.util.vo.SearchDetailVo;
import com.car.loan.project.xr.util.vo.SearchUrgentInfoVo;
import com.car.loan.project.xr.util.vo.SearchUrgentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author huangding
 * @date 2020/2/16 15:55
 */
@RestController
@RequestMapping("xr/search")
@Api(value = "查询管理", tags = "查询管理")
public class SearchController {

    @Autowired
    private ILoanService loanService;

    @Autowired
    private SearchService searchService;

    @PreAuthorize("@ss.hasPermi('search:business:list')")
    @GetMapping("business/list")
    @ApiOperation(value = "获取业务查询列表", response = LoanBaseInfo.class, responseContainer = "list")
    @DataStatus(loanStatusEnum = com.car.loan.common.enums.LoanStatusEnum.SEARCH_BUSINESS_LIST)
    public AjaxResult businessList(@Valid LoanBasePageParam loanBasePageParam) {
        return AjaxResult.success(loanService.page(loanBasePageParam));
    }


    @PreAuthorize("@ss.hasPermi('search:business:list')")
    @GetMapping("business/{loanId}")
    @ApiOperation(value = "获取业务查询详情", response = SearchBusinessVo.class)
    public AjaxResult businessDetail(@PathVariable Long loanId) {
        return AjaxResult.success(searchService.getSearchBusinessInfo(loanId));
    }


    @PreAuthorize("@ss.hasPermi('search:detail:list')")
    @GetMapping("detail/list")
    @ApiOperation(value = "获取明细查询列表", response = LoanBaseInfo.class, responseContainer = "list")
    @DataStatus(loanStatusEnum = com.car.loan.common.enums.LoanStatusEnum.SEARCH_DETAIL_LIST)
    public AjaxResult detailList(@Valid LoanBasePageParam loanBasePageParam) {
        return AjaxResult.success(loanService.page(loanBasePageParam));
    }

    @PreAuthorize("@ss.hasPermi('search:detail:list')")
    @GetMapping("detail/{loanId}")
    @ApiOperation(value = "获取明细查询详情", response = SearchDetailVo.class)
    public AjaxResult detailInfo(@PathVariable Long loanId) {
        return AjaxResult.success(searchService.getSearchDetailInfo(loanId));
    }


    @PreAuthorize("@ss.hasPermi('search:delete:list')")
    @GetMapping("delete/list")
    @ApiOperation(value = "获取删除查询列表", response = SearchDeleteVo.class, responseContainer = "list")
    public AjaxResult deleteList(@Valid LoanDeletePageParam loanDeletePageParam) {
        return AjaxResult.success(searchService.deletePage(loanDeletePageParam));
    }


    @PreAuthorize("@ss.hasPermi('search:delete:list')")
    @GetMapping("delete/{loanId}")
    @ApiOperation(value = "获取删除查询详情", response = LoanDeleteVo.class)
    public AjaxResult deleteInfo(@PathVariable Long loanId) {
        return AjaxResult.success(searchService.getSearchDeleteInfo(loanId));
    }


    @PreAuthorize("@ss.hasPermi('search:urgent:list')")
    @GetMapping("urgent/list")
    @ApiOperation(value = "获取催收查询列表", response = SearchUrgentVo.class, responseContainer = "list")
    public AjaxResult urgentList(@Valid LoanUrgentPageParam loanUrgentPageParam) {
        return AjaxResult.success(searchService.urgentPage(loanUrgentPageParam));
    }


    @PreAuthorize("@ss.hasPermi('search:urgent:list')")
    @GetMapping("urgent/{loanId}")
    @ApiOperation(value = "获取催收查询详情", response = SearchUrgentInfoVo.class)
    public AjaxResult urgentInfo(@PathVariable Long loanId) {
        return AjaxResult.success(searchService.getSearchUrgentInfo(loanId));
    }


}
